package com.sunkai.string;

import java.util.Arrays;

public class DealString {
//	private static final String src = "1,2,3,4,5,6,7,8,9,10";
	private static final String src = "sunkai,zhangxingyu,linfang,fuxingyu,niuchangqing,hanlongfei";
	
	/**
	 * split
	 * @param src
	 * @return
	 */
	private static String[] split(String src, String reg) {
//		if (reg == null || "".equals(reg)) {
//			return src.toCharArray();
//		}
		char[] chars = src.toCharArray();
		String[] result = new String[1];
		int count = 0;
		for (int i=0;i<chars.length;i++) {
			System.out.println(chars[i]);
			int next = i+1;
			if (next >= chars.length) {
				break;
			}
			if (reg.equals(String.valueOf(chars[next]))) {
				String[] temp = new String[count+1];
				for (int j=0;j<result.length;j++) {
					temp[j] = result[j];
				}
				temp[count] = String.valueOf(chars[i]); 
				result = temp;
//				result[count] = String.valueOf(chars[i]);
				count++;
			}
		}
		//System.out.println(src.toCharArray());
		return result;
	}
	
	public static void main(String[] args) {
		System.out.println(Arrays.toString(split(src, ",")));
//		System.out.println(Arrays.toString(src.split("<sdf")));
	}
}
